package com.itouchtv.yang.core.tools;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class FileList {
    public static List<String> getFileList(String directoryPath,String endStr){
        ArrayList<String> fileList = new ArrayList<>();
        File f = new File(directoryPath);
        if (!f.exists()) {
            System.out.println(directoryPath + " not exists");
            return null;
        }
        File fa[] = f.listFiles();
        if (!Objects.isNull(fa)){
            for (File ff:fa){
                if (ff.isFile()&&ff.getPath().endsWith(endStr)){
                    fileList.add(ff.getName());
                }
            }
        }
        return fileList;
    }
}
